<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<meta charset="utf-8">
<head>
    <th:block th:include="include :: header('出差列表')"/>
</head>
<body class="gray-bg">

<div class="container-div">
    <div class="row">
        <div class="col-sm-12 search-collapse">
            <form id="config-form">
                <div class="select-list">
                    <ul>
                        <li>
                            申请人：<input type="text" name="name"/>
                        </li>
                        <li>
                            出差类型：<select name="leaveType" th:with="type=${@dict.getType('businessType_type')}">
                            <option value="">所有</option>
                            <option th:each="dict:${type}" th:text="${dict.dictLabel}"
                                    th:value="${dict.dictValue}"></option>
                        </select>
                        </li>
                        <li>
                            申请日期：
                            <input name="createDate" type="text" id="createDate"
                                   placeholder="yyyy-MM-dd">
                        </li>

                        <li>
                            <a class="btn btn-success btn-rounded btn-sm" onclick="$.table.search()"><i
                                    class="fa fa-search"></i>&nbsp;搜索</a>
                            <a class="btn btn-success btn-rounded btn-sm" onclick="$.form.reset()"><i
                                    class="fa fa-refresh"></i>&nbsp;重置</a>
                        </li>
                    </ul>
                </div>
            </form>
        </div>

        <div class="btn-group-sm" id="toolbar" role="group">
            <a class="btn btn-success " onclick="$.operate.addFull()" shiro:hasPermission="'activiti:leave:add'">
                <i class="fa fa-plus"></i> 添加出差申请
            </a>
            <a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()"
               shiro:hasPermission="'activiti:leave:remove'">
                <i class="fa fa-remove"></i> 删除出差记录
            </a>
        </div>
        <div class="col-sm-12 select-table table-striped">
            <table id="bootstrap-table"></table>
        </div>
    </div>
</div>
<div th:include="include :: footer"></div>
<script th:inline="javascript">
    var removeFlag = [[${@permission.hasPermi('activiti:businessTrip:remove')}]];
    var listFlag = [[${@permission.hasPermi('activiti:businessTrip:list')}]];
    var data_businessTripType = [[${@dict.getType('businessTrip_type')}]];
    var prefix = ctx + "oa/businessTrip";

    $(function () {
        var options = {
            url: prefix + "/getBusinessTripList",
            createUrl: prefix + "/add",
            removeUrl: prefix + "/remove",
            modalName: "出差流程",
            /* 翻页记住选中 */
            rememberSelected: true,
            columns: [{
                checkbox: true
            },
                {
                    field: 'id',
                    title: '编号',
                    visible: false
                },
                {
                    field: 'user.userName',
                    title: '申请人'
                },
                {
                    field: 'dept.deptName',
                    title: '员工所在部门'
                },
                {
                    field: 'post',
                    title: '岗位职责'
                },
                {
                    field: 'createDate',
                    title: '申请时间'
                },
                {
                    field: 'businessTripType',
                    title: '出差类型',
                    formatter: function (value, row, index) {
                        return $.table.selectDictLabel(data_businessTripType, value);
                    }
                },
                {
                    field: 'content',
                    title: '出差原因'
                },
                {
                    field: 'currentTaskName',
                    title: '当前待执行环节'
                },
                {
                    field: 'startTime',
                    title: '出差开始时间'
                },
                {
                    field: 'endTime',
                    title: '出差结束时间'
                },

                {
                    title: '操作',
                    align: 'center',
                    formatter: function (value, row, index) {
                        var actions = [];
                        actions.push('<a class="btn btn-success btn-xs ' + listFlag + '" href="#" onclick="leaveDetail(\'' + row.id + '\')"><i class="fa fa-play-circle-o"></i>详情</a> ');
                        actions.push('<a class="btn btn-success btn-xs ' + removeFlag + '" href="#" onclick="$.operate.remove(\'' + row.id + '\')"><i class="fa fa-remove"></i>删除</a>');
                        return actions.join('');
                    }
                }]
        };
        $.table.init(options);
    });

    //详情
    function leaveDetail(id) {
        var url = prefix + "/form?id=" + id;
        $.modal.openFullS('出差详情', url);
    }

    $(function () {

        <!-- laydate时间选择器样式 -->
        layui.use('laydate', function () {
            var laydate = layui.laydate;


            laydate.render({
                elem: '#createDate',
                type: 'date',
                trigger: 'click'
            });

            // laydate.render({
            //     elem: '#endTime',
            //     type: 'datetime',
            //     trigger: 'click'
            // });
        });

    });
</script>
</body>
</html>